package com.cutepeer.notes;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;

import com.cutepeer.libonline.dialogs.ConfigDialog;
import com.cutepeer.libonline.settings.UserSigned;
import com.cutepeer.notes.dialogs.DialogMain;

/**
 * @since 
 * @author hoangcaomobile
 *
 */
public class SigninActivity extends FragmentActivity implements OnClickListener {

	private static Activity mActivity;

	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		vInit();	
		if (UserSigned.isUserLogged(getApplicationContext())) {
			startActivity(new Intent(getApplicationContext(), MainActivity.class));
			finish();
		} 
	}

	private void vInit() {
		mActivity = this;
		setContentView(R.layout.activity_welcome);
		findViewById(R.id.btSignin).setOnClickListener(this);
	}

	public static void vFinish() {
		mActivity.finish();
	}

	private void vSignin() {
		if (!ConfigDialog.isDialogFragmentShowing(getSupportFragmentManager(), ConfigDialog.dialogMain)) {
			new DialogMain().show(getSupportFragmentManager(), ConfigDialog.dialogMain);
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btSignin:
			vSignin();
			break;

		default:
			break;
		}
	}






}
